package com.xyht.sca_s.student_manage_system.modules.rxRegistrationWelcome.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.annotation.RequestPass;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationWelcome.entity.RxRegistrationWelcomeDelay;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationWelcome.entity.req.RxRegistrationWelcomeDelayAllowReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationWelcome.entity.req.RxRegistrationWelcomeDelayReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationWelcome.service.RxRegistrationWelcomeDelayService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 招生管理学生缓交申请表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-05-15
 */
@RestController
@RequestMapping("/rxRegistrationWelcome/delay")
@SecretBody
public class RxRegistrationWelcomeDelayController {

    @Resource
    private RxRegistrationWelcomeDelayService rxRegistrationWelcomeDelayService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @ApiOperation("缓交申请")
    @PostMapping("/add")
    @RequestPass
    public ResponseResult addRegistrationWelcomeDelay(@RequestBody RxRegistrationWelcomeDelayReq addReq) {
        return rxRegistrationWelcomeDelayService.addRegistrationWelcomeDelay(addReq);
    }

    @ApiOperation("查看申请列表")
    @GetMapping("/list")
    public ResponseResult getRegistrationWelcomeDelayList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                          @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                          @RequestParam(value = "stuName", required = false) String stuName,
                                                          @RequestParam(value = "idCard", required = false) String idCard,
                                                          @RequestParam(value = "allowStatus", required = false) Integer allowStatus
                                                          ) {
        return rxRegistrationWelcomeDelayService.getRegistrationWelcomeDelayList(pageNum, pageSize, stuName, idCard, allowStatus);
    }

    @ApiOperation("查看申请详情")
    @GetMapping("/detail")
    @RequestPass
    public ResponseResult getRegistrationWelcomeDelayDetail(@RequestParam(value = "applyId") String applyId) {
        return rxRegistrationWelcomeDelayService.getRegistrationWelcomeDelayDetail(applyId);
    }

    @ApiOperation("审批")
    @PostMapping("/allow")
    public ResponseResult allowRegistrationWelcomeDelayList(@RequestBody RxRegistrationWelcomeDelayAllowReq allowReq, HttpServletRequest request){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return rxRegistrationWelcomeDelayService.allowRegistrationWelcomeDelayList(allowReq,userId);
    }

    @ApiOperation("查看自己申请")
    @GetMapping("/getMyApply")
    @RequestPass
    public ResponseResult getMyApply(@RequestParam(value = "stuId") String stuId) {
        return rxRegistrationWelcomeDelayService.getMyApply(stuId);
    }

    @ApiOperation("撤销缓交申请")
    @PostMapping("/cancel")
    @RequestPass
    public ResponseResult cancelRegistrationWelcomeDelay(@RequestBody RxRegistrationWelcomeDelayReq cancelReq) {
        return rxRegistrationWelcomeDelayService.cancelRegistrationWelcomeDelay(cancelReq);
    }
}

